var mysql = require('mysql');

class sql{
  constructor(){
    this.connection = mysql.createConnection({
      host: 'localhost', // 填写你的mysql host
      user: 'root', // 填写你的mysql用户名
      password: '12345678', // 填写你的mysql密码
      database: 'blog'
    })
  }
  query(sql){
    this.connection.query(sql, async (err, results, filelds) => {
      // console.log(err,"err")
      // console.log(results,"sucess")
      if(err) return err;
      return results;
    })
  }
  release(){
    this.connection.release();
  }
}

module.exports = sql;